package com.handinfo.game;

import java.util.Calendar;
import java.util.Date;

/**
 * 拍卖Item
 * 
 * @author venizeng
 * 
 */
public class AuctionItem
{
	public long m_id_auction;// 拍卖Id
	public long m_time;// 放置时间
	public String m_time_str;// 放置时间
	public long m_money_auction;// 拍卖价格
	public long m_money_yikou;// 一口价
	public String m_name_sailer;
	//
	public ActorItem m_item;

	/**
	 * 获得测试用拍卖项
	 * @param num
	 * @return
	 */
	public static final AuctionItem[] getTestAuctionItems(int num)
	{
		AuctionItem[] items = new AuctionItem[num];
		for (int i = 0; i < items.length; i++) {
			items[i] = new AuctionItem();
			items[i].m_id_auction = i;
			items[i].m_time = i * 5;
			items[i].m_money_auction = 100 * num + i;
			items[i].m_money_yikou = 200 * num + i;
			items[i].m_item = ActorItem.getTestItem(ActorItem.TYPE_BAG_ROLE, i * 100 + 89) ;
		}
		return items;
	}

	/**
	 * 按时间进行排序
	 * @param items
	 * @return
	 */
	public static final AuctionItem[] orderByTime(AuctionItem[] items)
	{
		if (items == null || items.length == 0) {
			return null;
		}
		for (int i = 0; i < items.length - 1; i++) {
			for (int j = i + 1; j < items.length; j++) {
				if (items[i].m_time > items[j].m_time) {
					AuctionItem temp = items[i];
					items[i] = items[j];
					items[j] = temp;
				}
			}
		}
		return items;
	}

	/**
	 * 按价格进行排序
	 * @param items
	 * @return
	 */
	public static final AuctionItem[] orderByPrice(AuctionItem[] items)
	{
		if (items == null || items.length == 0) {
			return null;
		}
		for (int i = 0; i < items.length - 1; i++) {
			for (int j = i + 1; j < items.length; j++) {
				if (items[i].m_money_yikou > items[j].m_money_yikou) {
					AuctionItem temp = items[i];
					items[i] = items[j];
					items[j] = temp;
				}
			}
		}
		return items;
	}

	/**
	 * 将长整型数据转换成字符串时间
	 * 2012-2-20 下午01:47:20
	 * venizeng
	 * @param time
	 * @return
	 */
//	public static final String getStrTime(long time)
//	{
//		time *= 1000 ;
//		Date date = new Date(time) ;
//	    Calendar calendar = Calendar.getInstance();
//	    calendar.setTime(date);
//	    StringBuffer sb = new StringBuffer()
////	    .append(calendar.get(Calendar.YEAR)).append("年")
//	    .append((calendar.get(Calendar.MONTH)) + 1).append("月")
//	    .append(calendar.get(Calendar.DAY_OF_MONTH)).append("日")
//	    .append(calendar.get(Calendar.HOUR_OF_DAY)).append("时")
//	    .append(calendar.get(Calendar.MINUTE)).append("分");
//	    return sb.toString();
//	}

}
